/**
 * @name smPlugin
 * @description description
 * @version 1.0
 * @options
 *		option
 * @events
 *		event
 * @methods
 *		init
 *		publicMethod
 *		destroy
 */
 /** Slider **/
;(function($, window, undefined) {
	var pluginName = 'smBannerSlider';
	
	function Plugin(element, options) {
		this.element = $(element);
		this.options = $.extend({}, $.fn[pluginName].defaults, options);
		this.init();
	};

	Plugin.prototype = {
		init: function() {
			var plugin = this,
				that = plugin.element,
				slider = that.find(plugin.options.slider),
				sliderCol = slider.children(),
				controller = that.find(plugin.options.controller),
				conCol = controller.children(),
				preventDefault = false,
				index = controller.find('.' + plugin.options.activeClass).index();
			if(sliderCol.length <=1) return;
			sliderCol.not(sliderCol.eq(index)).hide();
			conCol.bind('click', function(e){
				e.preventDefault();
				// if(!preventDefault){
					// preventDefault = true;
					var subtitle = sliderCol.find('.subtitle');
					if($(this).hasClass(plugin.options.activeClass)){
						// preventDefault = false;
						return;
					}
					sliderCol.eq(controller.find('.' + plugin.options.activeClass).index()).fadeOut(1000);
					if(subtitle.length){
						sliderCol.eq(controller.find('.' + plugin.options.activeClass).index()).children('p').css('opacity', 0);
						sliderCol.eq(controller.find('.' + plugin.options.activeClass).index()).children('h3').children().css('opacity', 0);
						sliderCol.eq($(this).index()).children('p').css('opacity', 1);
						sliderCol.eq($(this).index()).children('h3').children().css('opacity', 1);
					}
					controller.find('.' + plugin.options.activeClass).removeClass(plugin.options.activeClass);
					sliderCol.eq($(this).index()).fadeIn(1000, function(){
						// preventDefault = false;
					});
					$(this).addClass(plugin.options.activeClass);
					index = $(this).index();
				// }
			});
			setInterval(function(){
				// if(!preventDefault){
					// preventDefault = true;
					var subtitle = sliderCol.find('.subtitle');
					sliderCol.eq(conCol.filter('.'+ plugin.options.activeClass).index()).fadeOut(1000);
					if(subtitle.length){
						sliderCol.eq(controller.find('.' + plugin.options.activeClass).index()).children('p').css('opacity', 0);
						sliderCol.eq(controller.find('.' + plugin.options.activeClass).index()).children('h3').children().css('opacity', 0);
					}
					conCol.filter('.'+ plugin.options.activeClass).removeClass(plugin.options.activeClass);
					index ++;
					if(index == sliderCol.length){
						index = 0;
					}
					if(subtitle.length){
						sliderCol.eq(index).children('p').css('opacity', 1);
						sliderCol.eq(index).children('h3').children().css('opacity', 1);
					}
					sliderCol.eq(index).fadeIn(1000, function(){
						// preventDefault = false;
					});
					conCol.eq(index).addClass(plugin.options.activeClass);
				// }
			}, 5000);	
		},
		publicMethod: function(param) {
			
		},
		destroy: function() {
		
		}
	};
	$.fn[pluginName] = function(options, params) {
		return this.each(function() {
			var instance = $.data(this, pluginName);
			if (!instance) {
				$.data(this, pluginName, new Plugin(this, options));
			} else if (instance[options]) {
				instance[options](params);
			} else {
				console.warn(options ? options + ' method is not exists in ' + pluginName : pluginName + ' plugin has been initialized');
			}
		});
	};

	$.fn[pluginName].defaults = {
		slider: 'value',
		controller: '',
		activeClass: 'active',
		afterSlide: function(){}
	};
}(jQuery, window));
/** customSelect **/
(function($, window, undefined) {
	var pluginName = 'smCustomSelect';
	
	function Plugin(element, options) {
		this.element = $(element);
		this.options = $.extend({}, $.fn[pluginName].defaults, options);
		this.init();
	};

	Plugin.prototype = {
		init: function() {
			var plugin = this,
				that = plugin.element;
				that.display = that.find(plugin.options.display);
				that.selectHandler = that.find('select');
				that.showItem = false;
				(plugin.options.triggerDisplay) && (that.triggerBtn = that.find(plugin.options.triggerBtn));
				(!plugin.options.customScroll) && (that.selectWrapper = $('<ul class="layer-option-lang" ></ul>').appendTo(document.body));
				if(plugin.options.customScroll){
					that.customScroll = $('<div class="layer-type-1">' +
												'<div class="scroll-block">' +
													'<ul>' +
													'</ul>' +
												'</div>' +
												'<div class="sm-scroll">' +
													'<div class="sm-scroll-dx">' +
														'<a href="javascript:void(0);">&nbsp;</a>' +
													'</div>' +
												'</div>' +
											'</div>').appendTo(document.body);
					that.selectWrapper = that.customScroll.find('ul');
					that.smScroll = that.customScroll.find('.sm-scroll-dx');
				}
			(!plugin.options.customScroll) && that.selectWrapper.css({
				top: that.offset().top + that.outerHeight(),
				left: that.offset().left
			});
			(plugin.options.customScroll) && that.customScroll.css({
				position: 'absolute',
				display: 'none',
				top: that.offset().top + that.outerHeight(),
				left: that.offset().left
			});
			that.selectWrapper.delegate('li', {
				'click': function(){
					that.display.html($(this).html());
					that.selectHandler.prop('selectedIndex', $(this).index());
					$.isFunction(plugin.options.afterChoosing) && plugin.options.afterChoosing.call($(this), that.selectHandler.val());
					(!plugin.options.closeSelect) && plugin.close();
					that.showItem = false;
				}
			});
			that.display.unbind('click.Open').bind('click.Open', function(){
				if(!that.showItem){
					plugin.open();
					that.showItem = true;
				}
				else{
					plugin.close();
					that.showItem = false;
				}
			});
			(plugin.options.triggerDisplay) && that.triggerBtn.bind('click', function(e){
				e.preventDefault();
				that.display.trigger('click.Open');
			});
			plugin.update();
			$(document).bind('mousedown.customSelect', function(e){
				if(!$(e.target).is(that.triggerBtn) && !$(e.target).is(that.display) && !$(e.target).is(that.selectWrapper.children()) && !$(e.target).closest('.layer-type-1').length){
					if(that.showItem){
						that.display.trigger('click.Open');
					}
				}
				// if(plugin.options.customScroll){
					// if(!$(e.target).closest('.layer-type-1').length){
						// if(that.showItem){
							// that.display.trigger('click.Open');
						// }
					// }
				// }
			});
			$(window).bind('resize', function(){
				(!plugin.options.customScroll) && that.selectWrapper.css({
					top: that.offset().top + that.height(),
					left: that.offset().left
				});
				(plugin.options.customScroll) && that.customScroll.css({
					top: that.offset().top + that.height(),
					left: that.offset().left
				});
			});
		},
		open: function(param){
			var plugin = this,
				that = plugin.element;
				display = that.display;
				(!plugin.options.customScroll) && (selectWrapper = that.selectWrapper);
				(!plugin.options.customScroll) && selectWrapper.slideDown(500, function(){
					$.isFunction(plugin.options.afterOpen) && plugin.options.afterOpen();
				});
				(plugin.options.customScroll) && (customScroll = that.customScroll);
				(plugin.options.customScroll) && customScroll.slideDown(500, function(){
					if(plugin.options.customScroll){
						if(!customScroll.data('smCustomScroll')){
							customScroll.smCustomScroll({
								contentArea : 'div.scroll-block',
								wrapperContent : 'ul',
								scrollBar : '.sm-scroll .sm-scroll-dx',
								scrollBarBtn : 'a'
							});
						}
					}	
					$.isFunction(plugin.options.afterOpen) && plugin.options.afterOpen();
				});
		},
		close: function(){
			var plugin = this,
				that = plugin.element;
				display = that.display;
				(!plugin.options.customScroll) && (selectWrapper = that.selectWrapper);
				(!plugin.options.customScroll) && selectWrapper.slideUp(500, function(){
					$.isFunction(plugin.options.afterClose) && plugin.options.afterClose();
				});
				(plugin.options.customScroll) && (customScroll = that.customScroll);
				(plugin.options.customScroll) && customScroll.slideUp(500, function(){
					$.isFunction(plugin.options.afterClose) && plugin.options.afterClose();
				});
		},
		destroy: function(){
			
		},
		update: function(){
			var plugin = this,
				that = plugin.element;
				selectHandler = that.selectHandler;
				selectWrapper = that.selectWrapper;
				(plugin.options.customScroll) && (customScroll = that.customScroll);
				selectHandler.children().each(function(index){
					if(plugin.options.customOption){
						$('<li>'+ plugin.options.optionTemplate[index] + $(this).html() +'</li>').appendTo(selectWrapper);
					}
					else{
						$('<li><a title="'+ $(this).html() +'" href="javascript:void(0);">'+ $(this).html() +'</a></li>').appendTo(selectWrapper);
					}
				});
				if(!plugin.options.customScroll){
					selectWrapper.hide();
					selectWrapper.css({
						height: that.outerHeight()* plugin.options.optionDisplay
					});
				}
				if(plugin.options.customScroll){
					customScroll.css({
						height: (that.display.outerHeight() + 5)* plugin.options.optionDisplay
					});
					selectWrapper.parent().css({
						height: (that.display.outerHeight() + 5)* plugin.options.optionDisplay
					});
					that.smScroll.css({
						height: (that.display.outerHeight() + 5)* plugin.options.optionDisplay
					});
				}
		}
	};

	$.fn[pluginName] = function(options, params) {
		return this.each(function() {
			var instance = $.data(this, pluginName);
			if (!instance) {
				$.data(this, pluginName, new Plugin(this, options));
			} else if (instance[options]) {
				instance[options](params);
			} else {
				console.warn(options ? options + ' method is not exists in ' + pluginName : pluginName + ' plugin has been initialized');
			}
		});
	};

	$.fn[pluginName].defaults = {
		display: 'span',
		
		triggerDisplay: false,
		triggerBtn: '',
		
		customOption: false,
		optionTemplate: [],
		
		customScroll: false,
		
		optionDisplay: 4,
		
		closeSelect: false,
		
		afterOpen: function(){},
		afterClose: function(){},
		afterChoosing: function(){}
	};
}(jQuery, window));
/** ZoomImage **/
(function($, window, undefined) {
	var pluginName = 'smMagnifyingGlass';
	
	function Plugin(element, options) {
		this.element = $(element);
		this.options = $.extend({}, $.fn[pluginName].defaults, options);
		this.init();
	};

	Plugin.prototype = {
		init: function() {
			var plugin = this,
				that = plugin.element;
			if(plugin.options.zoom <=1) return;	
				that.irisCamera = that.find('span span');
				that.img = that.find('img');
				that.imgHeight = that.img.height();
				that.imgWidth = that.img.width();
				that.initDrag = false;
				that.firstCoor = {};
				greaterHeight = that.imgHeight - that.imgHeight*plugin.options.zoom;
				greaterWidth = that.imgWidth - that.imgWidth*plugin.options.zoom;
				
			that.irisCamera.hover(
				function(){
					that.img.css({
						height: that.imgHeight*plugin.options.zoom,
						width: that.imgWidth*plugin.options.zoom,
						marginTop: greaterHeight/2,
						marginLeft: greaterWidth/2 
					});
				},
				function(){
					that.img.css({
						height: that.imgHeight,
						width: that.imgWidth,
						marginTop: 0,
						marginLeft: 0
					});
				}
			);
			that.irisCamera.unbind('.zoom').bind({
				'mousedown.zoom': function(e){
					e.preventDefault();	
					that.initDrag = true;
					that.firstCoor = {
						top: e.pageY,
						left: e.pageX
					}
				},
				'mouseup.zoom': function(e){
					e.preventDefault();	
					that.initDrag = false;
					//that.firstCoor ={};
				},
				'mousemove.zoom': function(e){
					e.preventDefault();	
					if(that.initDrag){
						var moveY = e.pageY - that.firstCoor.top;
						var moveX = e.pageX - that.firstCoor.left;
						if(e.pageY > that.firstCoor.top){
							if(parseInt(that.img.css('margin-top')) + moveY < 0){
								that.img.css({
									marginTop: parseInt(that.img.css('margin-top')) + moveY
								});
							}
							else{
								that.img.css({
									marginTop: 0
								});
							}
						}
						else{
							if(parseInt(that.img.css('margin-top')) + moveY > greaterHeight){
								that.img.css({
									marginTop: parseInt(that.img.css('margin-top')) + moveY
								});
							}
							else{
								that.img.css({
									marginTop: greaterHeight
								});
							}
						}
						if(e.pageX > that.firstCoor.left){
							if(parseInt(that.img.css('margin-left')) + moveX < 0){
								that.img.css({
									marginLeft: parseInt(that.img.css('margin-left')) + moveX
								});
							}
							else{
								that.img.css({
									marginLeft: 0
								});
							}
						}
						else{
							if(parseInt(that.img.css('margin-left')) + moveX > greaterWidth){
								that.img.css({
									marginLeft: parseInt(that.img.css('margin-left')) + moveX
								});
							}
							else{
								that.img.css({
									marginLeft: greaterWidth
								});
							}
						}
					}
				}
			});
		}
	};

	$.fn[pluginName] = function(options, params) {
		return this.each(function() {
			var instance = $.data(this, pluginName);
			if (!instance) {
				$.data(this, pluginName, new Plugin(this, options));
			} else if (instance[options]) {
				instance[options](params);
			} else {
				console.warn(options ? options + ' method is not exists in ' + pluginName : pluginName + ' plugin has been initialized');
			}
		});
	};

	$.fn[pluginName].defaults = {
		zoom: 1.5
	};
}(jQuery, window));
/** Menu **/
(function($, window, undefined) {
	var pluginName = 'smMenu';
	
	function Plugin(element, options) {
		this.element = $(element);
		this.options = $.extend({}, $.fn[pluginName].defaults, options);
		this.init();
	};

	Plugin.prototype = {
		init: function() {
			var plugin = this,
				that = plugin.element;
				that.active = that.find('.active');
			that.find('li').hover(
				function(e){
					if($(this).parent().is('#nav')) return;
					$(this).parent().find('.active').removeClass('active');
					e.preventDefault();
					$(this).addClass('active');
				},
				function(e){
					if($(this).parent().is('#nav')) return;
					e.preventDefault();
					$(this).removeClass('active');
				}
			);
			that.bind('mouseleave', function(){
				that.active.addClass('active');
			});
		},
		publicMethod: function(param) {
			
		},
		destroy: function() {
		
		}
	};

	$.fn[pluginName] = function(options, params) {
		return this.each(function() {
			var instance = $.data(this, pluginName);
			if (!instance) {
				$.data(this, pluginName, new Plugin(this, options));
			} else if (instance[options]) {
				instance[options](params);
			} else {
				console.warn(options ? options + ' method is not exists in ' + pluginName : pluginName + ' plugin has been initialized');
			}
		});
	};

	$.fn[pluginName].defaults = {
		
	};
}(jQuery, window));
/** popup **/
(function($, window, undefined) {
	var pluginName = 'smPopup';
	
	function Plugin(element, options) {
		this.element = $(element);
		this.options = $.extend({}, $.fn[pluginName].defaults, options);
		this.init();
	};

	Plugin.prototype = {
		init: function() {
			var plugin = this,
				that = plugin.element;
				// if(!$('.Popup-Overlay').length){
					that.popup = $('<div class="Popup-Overlay"></div>').appendTo(document.body);
				// }
				// else{
					// that.popup = $('.Popup-Overlay');
				// }
				that.popup.css({
					top: 0,
					left: 0,
					background: plugin.options.background,
					width: '100%',
					height: '100%',
					display: 'none',
					zIndex: plugin.options.zIndex,
					position: 'fixed'
				});
				if(plugin.options.animation){
					that.popup.css({
						opacity: 0
					});
				}
				else{
					that.popup.css({
						display: 'none'
					});
				}
				if(plugin.options.autoShow){
					plugin.open();
				}
				if(plugin.options.btnClose){
					that.btnClose = that.find(plugin.options.triggerClose);
					that.btnClose.bind('click', function(e){
						e.preventDefault();
						plugin.close();
					});
				}
				else{
					that.popup.bind('click', function(){
						plugin.close();
					});
				}
				$(window).bind('resize', function(){
					that.css({
						position : ($(window).height() > that.height()) ? 'fixed' : 'absolute',	
						top: ($(window).height() > that.height()) ? (Math.max(0, ($(window).height() - that.height())/2)) : (Math.max(0, ($(window).height() - that.height())/2 + $(window).scrollTop())),
						left: ($(window).width() > that.width()) ? (Math.max(0, ($(window).width() - that.width())/2)) : (Math.max(0, ($(window).width() - that.width())/2 + $(window).scrollLeft()))
					})
				});
		},
		open: function(param) {
			var plugin = this,
				that = plugin.element;
				popup = that.popup;
			if(plugin.options.animation){
				$.isFunction(plugin.options.beforeOpen) && plugin.options.beforeOpen.call(that, param);
				popup.fadeTo(plugin.options.duration, plugin.options.popupOpacity, function(){
					$.isFunction(plugin.options.afterOpen) && plugin.options.afterOpen.call(that, param);
				});
				Number(popup.css('zIndex')) > 0 && that.css('zIndex', Number(popup.css('zIndex')) + 1);
				that.css({
					position : ($(window).height() > that.height()) ? 'fixed' : 'absolute',	
					top: ($(window).height() > that.height()) ? (Math.max(0, ($(window).height() - that.height())/2)) : (Math.max(0, ($(window).height() - that.height())/2 + $(window).scrollTop())),
					left: ($(window).width() > that.width()) ? (Math.max(0, ($(window).width() - that.width())/2)) : (Math.max(0, ($(window).width() - that.width())/2 + $(window).scrollLeft()))
				}).fadeIn(plugin.options.duration);
			}
			else{
				popup.css('opacity', plugin.options.popupOpacity).show();
				Number(popup.css('zIndex')) > 0 && that.css('zIndex', Number(popup.css('zIndex')) + 1);
				that.css({
					position : ($(window).height() > that.height()) ? 'fixed' : 'absolute',	
					top: ($(window).height() > that.height()) ? (Math.max(0, ($(window).height() - that.height())/2)) : (Math.max(0, ($(window).height() - that.height())/2 + $(window).scrollTop())),
					left: ($(window).width() > that.width()) ? (Math.max(0, ($(window).width() - that.width())/2)) : (Math.max(0, ($(window).width() - that.width())/2 + $(window).scrollLeft()))
				}).show();
			}
		},
		close: function(param) {
			var plugin = this,
				that = plugin.element;
				popup = that.popup;
			if(plugin.options.animation){
				popup.fadeOut(plugin.options.duration, function(){
					$.isFunction(plugin.options.afterClose) && plugin.options.afterClose.call(that,param);
				});
				that.fadeOut(plugin.options.duration);
			}
			else{
				popup.hide();
				that.hide();
			}
		}
	};

	$.fn[pluginName] = function(options, params) {
		return this.each(function() {
			var instance = $.data(this, pluginName);
			if (!instance) {
				$.data(this, pluginName, new Plugin(this, options));
			} else if (instance[options]) {
				instance[options](params);
			} else {
				console.warn(options ? options + ' method is not exists in ' + pluginName : pluginName + ' plugin has been initialized');
			}
		});
	};

	$.fn[pluginName].defaults = {
		background: 'white',
		autoShow: false,
		animation: true,
		
		btnClose: false,
		triggerClose: '',
		
		popupOpacity: 0.5,
		duration: 2000,
		zIndex: 999,
		
		beforeOpen: function(){},
		afterOpen: function(){},
		afterClose: function(){}
	};
}(jQuery, window));
/** validation **/
(function($, window, undefined) {
	var pluginName = 'smValidation';
	
	function Plugin(element, options) {
		this.element = $(element);
		this.options = $.extend({}, $.fn[pluginName].defaults, options);
		this.init();
	};
	function hint(message){
		var el = $(this),
			layer = 'alert-layer';
		
		if(!$('.' + layer).length){
			layer = $('<div class="' + layer + '">' + message + '</div>').appendTo(document.body);
		}
		else{
			return;
		}
		el.focus();
		
		layer.css({
			'top': el.offset().top + el.outerHeight(),
			'left': el.offset().left
		});	
		
		setTimeout(function(){
			layer.remove();
		}, 2000);	
	}
	
	Plugin.prototype = {
		init: function() {
			var plugin = this,
				that = plugin.element;
			if(!that.is('form')){
				return;
			};
			// for(var i = 0; i < plugin.options.rules.length; i ++){
				// var rule = plugin.options.rules[i],
					// el = that.find('[name="'+ rule.name +'"]');
				// if(rule.init){
					// !rule.checkDefault && el.val(rule.init);
					// el
					// .data('initText', rule.init)
					// .bind({
						// 'focus.validate': function(){
							// var self = $(this);
							// self.val() === self.data('initText') && self.val('');
						// },
						// 'blur.validate': function(){	
							// var self = $(this);
							// $.trim(self.val()) === '' && self.val(self.data('initText'));
						// }
					// })
					// .triggerHandler('blur');
				// }
			// }
			// plugin.options.customSubmit && that.find(plugin.options.triggerSubmit).bind('click', function(){
				// $(this).closest('form').trigger('submit.formValidation');
			// });
			that.bind('submit.formValidation', function(){
				var testing = true;
				for(i = 0; i < plugin.options.rules.length; i++){
					var rule = plugin.options.rules[i],
						el = that.find('[name="'+ rule.name +'"]');
					if(rule.valid){
						var value = $.trim(el.val()),
							valid = rule.valid.split('|'),
							message = rule.message.split('|');
							
						if(rule.reposition){
							el = rule.reposition;
						}
						$.each(valid, function(index){
							switch(valid[index]){
								case 'required':
									if(!value || value == rule.init){
										hint.apply(el, [message[index]]);
										testing = false;
									}
									break;			
							};
							if(!testing){
								return false;
							};
						});	
					};
					if(!testing){
						return false;
					};
				};
				if(plugin.options.beforeSubmit){
					plugin.options.beforeSubmit.apply( that, arguments )
				}
				if(plugin.options.onSubmit){
					return plugin.options.onSubmit.apply( that, arguments );
				}
				return true;	
			});
		},
		publicMethod: function(param) {
			
		},
		destroy: function() {
		
		}
	};

	$.fn[pluginName] = function(options, params) {
		return this.each(function() {
			var instance = $.data(this, pluginName);
			if (!instance) {
				$.data(this, pluginName, new Plugin(this, options));
			} else if (instance[options]) {
				instance[options](params);
			} else {
				console.warn(options ? options + ' method is not exists in ' + pluginName : pluginName + ' plugin has been initialized');
			}
		});
	};

	$.fn[pluginName].defaults = {
		rules:[],
		beforeSubmit: null,
		onSubmit: null,
		customSubmit: false,
		triggerSubmit: ''
	};
}(jQuery, window));
/** AutoValidation **/
(function($, window, undefined) {
	var pluginName = 'smAutoValidation';
	
	function Plugin(element, options) {
		this.element = $(element);
		this.options = $.extend({}, $.fn[pluginName].defaults, options);
		this.init();
	};
	function hint(message){
		var el = $(this),
			layer = 'alert-layer';
		
		if(!$('.' + layer).length){
			layer = $('<div class="' + layer + '">' + message + '</div>').appendTo(document.body);
		}
		else{
			return;
		}
		el.focus();
		
		layer.css({
			'top': el.offset().top + el.outerHeight(),
			'left': el.offset().left
		});	
		
		setTimeout(function(){
			layer.remove();
		}, 2000);	
	}
	
	Plugin.prototype = {
		init: function() {
			var plugin = this,
				that = plugin.element;
			if(!that.is('form')){
				return;
			};
			for(var i = 0; i < plugin.options.rules.length; i ++){
				var rule = plugin.options.rules[i],
					el = that.find('[type="'+ rule.type +'"]');
					if(rule.element){
						el = that.find(rule.element);
					}
				if(rule.init){
					el
					.data('initText', rule.init)
					.bind({
						'focus.validate': function(){
							var self = $(this);
							self.val() === self.data('initText') && self.val('');
						},
						'blur.validate': function(){	
							var self = $(this);
							$.trim(self.val()) === '' && self.val(self.data('initText'));
						}
					})
					.triggerHandler('blur');
				}
			}
			plugin.options.customSubmit && that.find(plugin.options.triggerSubmit).bind('click', function(){
				$(this).closest('form').trigger('submit.formValidation');
			});
			that.unbind('submit.formValidation').bind('submit.formValidation', function(){
				var testing = true;
				for(i = 0; i < plugin.options.rules.length; i++){
					var rule = plugin.options.rules[i],
						el = that.find('[type="'+ rule.type +'"]');
						if(rule.element){
							el = that.find(rule.element);
						}
					if (!el.length) {
						continue;
					}
					if(rule.valid){
						var value = $.trim(el.val()),
							valid = rule.valid.split('|'),
							message = rule.message.split('|');
							
						$.each(valid, function(index){
							switch(valid[index]){
								case 'required':
									if(!value || value == el.data('initText')){
									if(rule.reposition){
										el = el.prev();
									}
										hint.apply(el, [message[index]]);
										testing = false;
									}
									break;
								case 'email':
									if(! /^[\w-]+(\.[\w-]+)*@([A-Za-z0-9-]+(\.[A-Za-z0-9-]+)*?\.[A-Za-z]{2,6}|(\d{1,3}\.){3}\d{1,3})(:\d{4})?$/.test(value)){
										hint.apply(el, [message[index]]);
										testing = false;
									}
									break;
								case 'checked':
									if(el.is('span')){
										if(!el.is('.checked')){
											testing = false;
											hint.apply(el, [message[index]]);
										}		
									}
									else if(!el.is('span')){
										if(!el.is(':checked')){
											testing = false;
											hint.apply(el, [message[index]]);
										}			
									}
									break;						
							};
							if(!testing){
								return false;
								console.log(2);
							};
						});	
					};
					if(!testing){
						return false;
					};
				};
				if(plugin.options.beforeSubmit){
					plugin.options.beforeSubmit.apply( that, arguments )
				}
				if(plugin.options.onSubmit){
					return plugin.options.onSubmit.apply( that, arguments );
				}
				return true;	
			});
		},
		publicMethod: function(param) {
			
		},
		destroy: function() {
		
		}
	};

	$.fn[pluginName] = function(options, params) {
		return this.each(function() {
			var instance = $.data(this, pluginName);
			if (!instance) {
				$.data(this, pluginName, new Plugin(this, options));
			} else if (instance[options]) {
				instance[options](params);
			} else {
				console.warn(options ? options + ' method is not exists in ' + pluginName : pluginName + ' plugin has been initialized');
			}
		});
	};

	$.fn[pluginName].defaults = {
		rules:[],
		beforeSubmit: null,
		onSubmit: null,
		customSubmit: false,
		triggerSubmit: ''
	};
}(jQuery, window));
/** hoverSlider **/
(function($, window, undefined) {
	var pluginName = 'smHoverSlider';
	
	function Plugin(element, options) {
		this.element = $(element);
		this.options = $.extend({}, $.fn[pluginName].defaults, options);
		this.init();
	};

	Plugin.prototype = {
		init: function() {
			var plugin = this,
				that = plugin.element;
				that.slideContent = that.find(plugin.options.slideContent);
				that.navHover = that.find(plugin.options.navHover);
				that.slideContent.children().not(':eq('+ that.navHover.find('.' + plugin.options.activeClass).index() +')').each(function(){
					$(this).hide();
				});
				//that.preventHover = false;
			that.navHover.children().bind('mouseenter.smHoverSlider', function(){
				if(!$(this).hasClass(plugin.options.activeClass) ){
					//that.preventHover = true;
					var active = that.navHover.find('.' + plugin.options.activeClass);
					// that.slideContent.children().eq(active.index()).fadeOut(100);
					that.slideContent.children().eq(active.index()).hide();
					active.removeClass(plugin.options.activeClass);
					that.slideContent.children().eq($(this).index()).show();
					// that.slideContent.children().eq($(this).index()).fadeIn(100,
					// function(){
						// that.preventHover = false;
					// });
					$(this).addClass(plugin.options.activeClass);
				}
			});
		},
		publicMethod: function(param) {
			
		},
		destroy: function() {
		
		}
	};

	$.fn[pluginName] = function(options, params) {
		return this.each(function() {
			var instance = $.data(this, pluginName);
			if (!instance) {
				$.data(this, pluginName, new Plugin(this, options));
			} else if (instance[options]) {
				instance[options](params);
			} else {
				console.warn(options ? options + ' method is not exists in ' + pluginName : pluginName + ' plugin has been initialized');
			}
		});
	};

	$.fn[pluginName].defaults = {
		slideContent: '',
		navHover:'',
		activeClass: 'active'
	};
}(jQuery, window));
/** hoverChangeClass **/
(function($, window, undefined) {
	var pluginName = 'smHoverChangeClass';
	
	function Plugin(element, options) {
		this.element = $(element);
		this.options = $.extend({}, $.fn[pluginName].defaults, options);
		this.init();
	};

	Plugin.prototype = {
		init: function() {
			var plugin = this,
				that = plugin.element;
				classChanged = that.find('.' + plugin.options.classChanged);
			classChanged.hover(
				function(){
					$(this).removeClass(plugin.options.classChanged).addClass(plugin.options.changeClassInto);
				},
				function(){
					$(this).removeClass(plugin.options.changeClassInto).addClass(plugin.options.classChanged);
				}
			);
		},
		publicMethod: function(param) {
			
		},
		destroy: function() {
		
		}
	};

	$.fn[pluginName] = function(options, params) {
		return this.each(function() {
			var instance = $.data(this, pluginName);
			if (!instance) {
				$.data(this, pluginName, new Plugin(this, options));
			} else if (instance[options]) {
				instance[options](params);
			} else {
				console.warn(options ? options + ' method is not exists in ' + pluginName : pluginName + ' plugin has been initialized');
			}
		});
	};

	$.fn[pluginName].defaults = {
		classChanged: '',
		changeClassInto: ''
	};
}(jQuery, window));
/** moreDetail **/
(function($, window, undefined) {
	var pluginName = 'smMoreDetail';
	
	function Plugin(element, options) {
		this.element = $(element);
		this.options = $.extend({}, $.fn[pluginName].defaults, options);
		this.init();
	};

	Plugin.prototype = {
		init: function() {
			var plugin = this,
				that = plugin.element;
				that.detailContent = that.find(plugin.options.detailContent);
				that.triggerDetailClass = that.find('.' + plugin.options.triggerDetailClass);
			if(!that.detailContent.length || !that.triggerDetailClass.length) return;
				that.slideUp = false;
			that.triggerDetailClass.bind('click', function(e){
				e.preventDefault();
				if(!that.slideUp){
					if(plugin.options.animation == 'slide'){
						that.detailContent.slideDown(500);
					}
					else{
						that.detailContent.fadeIn(500);
					}
					that.slideUp = true;
					(plugin.options.setActiveClass) && $(this).addClass(plugin.options.activeClass);
				}
				else{
					if(plugin.options.animation == 'slide'){
						that.detailContent.slideUp(500);
					}
					else{
						that.detailContent.fadeOut(500);
					}
					that.slideUp = false;
					(plugin.options.setActiveClass) && $(this).removeClass(plugin.options.activeClass);
				}
			});
		},
		publicMethod: function(param) {
			
		},
		destroy: function() {
		
		}
	};

	$.fn[pluginName] = function(options, params) {
		return this.each(function() {
			var instance = $.data(this, pluginName);
			if (!instance) {
				$.data(this, pluginName, new Plugin(this, options));
			} else if (instance[options]) {
				instance[options](params);
			} else {
				console.warn(options ? options + ' method is not exists in ' + pluginName : pluginName + ' plugin has been initialized');
			}
		});
	};

	$.fn[pluginName].defaults = {
		detailContent: '',
		triggerDetailClass: '',
		animation: 'slide',
		setActiveClass: true,
		activeClass: 'active'
	};
}(jQuery, window));
/**
*
* showDetail
*
**/
(function($, window, undefined) {
	var pluginName = 'smShowDetail';
	function Plugin(element, options) {
		this.element = $(element);
		this.options = $.extend({}, $.fn[pluginName].defaults, options);
		this.init();
	};

	Plugin.prototype = {
		init: function() {
			var plugin = this,
				that = plugin.element;
				that.detailContent = that.find(plugin.options.detailContent);
				that.triggerExtendable = that.find(plugin.options.triggerExtendable);
				that.triggerCollapsible = that.find(plugin.options.triggerCollapsible);
			if(!that.detailContent.length || !that.triggerExtendable.length || !that.triggerCollapsible.length) return;
				that.slideUp = false;
			that.triggerExtendable.bind('click', function(e){
				var self = $(this);
				e.preventDefault();
				that.detailContent.slideDown(300,function(){
					// self.hide();
				});
				$(this).fadeOut(50);
			});
			that.triggerCollapsible.bind('click', function(e){
				e.preventDefault();
				that.detailContent.slideUp(300, function(){
					// that.triggerExtendable.fadeIn(100);
					that.triggerExtendable.show();
				});
					// that.triggerExtendable.show();
			});
		},
		publicMethod: function(param) {
			
		},
		destroy: function() {
		
		}
	};

	$.fn[pluginName] = function(options, params) {
		return this.each(function() {
			var instance = $.data(this, pluginName);
			if (!instance) {
				$.data(this, pluginName, new Plugin(this, options));
			} else if (instance[options]) {
				instance[options](params);
			} else {
				console.warn(options ? options + ' method is not exists in ' + pluginName : pluginName + ' plugin has been initialized');
			}
		});
	};

	$.fn[pluginName].defaults = {
		detailContent: '',
		triggerExtendable: '',
		triggerCollapsible: ''
	};
}(jQuery, window));
/**
*
* showAvailableFilm
*
**/
(function($, window, undefined) {
	var pluginName = 'smShowAvailableFilm';
	function Plugin(element, options) {
		this.element = $(element);
		this.options = $.extend({}, $.fn[pluginName].defaults, options);
		this.init();
	};

	Plugin.prototype = {
		init: function() {
			var plugin = this,
				that = plugin.element;
				that.detailContent = that.find(plugin.options.detailContent);
				that.triggerExtendable = that.find(plugin.options.triggerExtendable);
				that.extend = false;
			if(!that.detailContent.length || !that.triggerExtendable.length) return;
			that.triggerExtendable.bind('click', function(e){
				var self = $(this);
				e.preventDefault();
				if(!that.extend){
					that.extend = true;
					that.detailContent.slideDown(300,function(){
						self.addClass(plugin.options.extendClass);
					});
				}
				else if(that.extend){
					that.extend = false;
					that.detailContent.slideUp(300,function(){
						self.removeClass(plugin.options.extendClass);
					});
				}
			});
		},
		publicMethod: function(param) {
			
		},
		destroy: function() {
		
		}
	};

	$.fn[pluginName] = function(options, params) {
		return this.each(function() {
			var instance = $.data(this, pluginName);
			if (!instance) {
				$.data(this, pluginName, new Plugin(this, options));
			} else if (instance[options]) {
				instance[options](params);
			} else {
				console.warn(options ? options + ' method is not exists in ' + pluginName : pluginName + ' plugin has been initialized');
			}
		});
	};

	$.fn[pluginName].defaults = {
		detailContent: '.ui-accordion-content',
		triggerExtendable: '.ui-accordion-header a',
		extendClass: 'active'
	};
}(jQuery, window));
/**
*
* showGallery
*
**/
(function($, window, undefined) {
	var pluginName = 'smShowGallery';
	
	function Plugin(element, options) {
		this.element = $(element);
		this.options = $.extend({}, $.fn[pluginName].defaults, options);
		this.init();
	};
	function loadImage(that){
		that.vars.src = that.vars.thumbnailCol.eq(that.vars.index).children('a').attr('href');
		that.vars.currentImgIndex.html((that.vars.index + 1) + '/' + that.vars.thumbnailCol.length);
		var image = new Image();
		image.onload = function(){
			that.vars.imgLoading.attr('src', this.src);
			var heigtImage = (this.height <= 630 ) ? (this.height) : (630);
			var widthImage = (this.height <= 630 ) ? (this.width) : (this.width*630/this.height);
			// that.bigWrapper.find('#load-content').stop().animate({
				// top: (Math.max(0, ($(window).height() - heigtImage)/2)),
				// left: (Math.max(0, ($(window).width() - widthImage)/2)),
				// width: widthImage,
				// height: heigtImage 
			// }, 1000, function(){
				// that.loadIcon.hide();
				// that.imgLoading.show();
			// });
			that.vars.bigWrapper.stop().animate({
				top: (that.vars.bigWrapper.css('position') == 'fixed') ? (Math.max(0, ($(window).height() - (heigtImage + 90))/2)) : (Math.max(0, ($(window).height() - (heigtImage + 90))/2 + $(window).scrollTop())),
				left: (that.vars.bigWrapper.css('position') == 'fixed') ? (Math.max(0, ($(window).width() - (widthImage + 50))/2)) : (Math.max(0, ($(window).width() - (widthImage + 50))/2 + $(window).scrollLeft()))
			//	width: widthImage,
			//	height: heigtImage 
			}, 1000, function(){
				that.vars.loadIcon.hide();
				that.vars.imgLoading.css({
					height: heigtImage,
					width: widthImage
				}).show();
			});
			that.vars.bigWrapper.find('#load-content').stop().animate({
				width: widthImage,
				height: heigtImage 
			},1000);
		};
		image.src = that.vars.src;
	}

	function loadFrame(that){
		if(that.classCheckForIfram){
			that.id = getUID();
			if(!that.defaultsLink){
				that.inputFrame = $('<iframe id="cboxIframe" class="cboxIframe" scrolling="no" name="'+that.id+'" src="'+ that.frameHref +'">').appendTo(that.wrapperFrame);
			}
			if(that.defaultsLink){
				that.inputFrame = $('<iframe id="cboxIframe" class="cboxIframe" scrolling="no" name="'+that.id+'" src="'+ window.location.hostname +'/en/content/join-us">').appendTo(that.wrapperFrame);
			}
			that.inputFrame.css('opacity',0);
			that.inputFrame.bind('load', function(){
				var heightFrame = that.inputFrame.contents().children().children('body').children('#container').height();
				var widthFrame = that.inputFrame.contents().children().children('body').children('#container').width();
				that.loadIcon.hide();
				that.bigWrapper.stop().animate({
					top: (that.bigWrapper.css('position') == 'fixed') ? (Math.max(0, ($(window).height() - (widthFrame + 50))/2)) : (Math.max(0, ($(window).height() - (widthFrame + 50))/2 + $(window).scrollTop())),
					left: (that.bigWrapper.css('position') == 'fixed') ? (Math.max(0, ($(window).width() - (widthFrame + 50))/2)) : (Math.max(0, ($(window).width() - (widthFrame + 50))/2 + $(window).scrollLeft()))
				}, 1000, function(){
					that.loadIcon.hide();
					that.inputFrame.css({
						height: heightFrame,
						width: widthFrame,
						opacity: 1
					});
				});
				that.bigWrapper.find('#load-content').stop().animate({
					width: widthFrame,
					height: widthFrame 
				},1000);
			});
		}
		if(!that.classCheckForIfram){
			that.inputFrame = $('<img id="cboxIframe" class="cboxIframe" src="http://dxo.local.sutrix.com/en/content/join-us">').appendTo(that.wrapperFrame);
			that.inputFrame.css('opacity',0);
			var image = new Image();
			image.onload = function(){
				that.inputFrame.attr('src', this.src);
				var heigtImage = (this.height <= 630 ) ? (this.height) : (630);
				var widthImage = (this.height <= 630 ) ? (this.width) : (this.width*630/this.height);
				that.bigWrapper.stop().animate({
					top: (that.bigWrapper.css('position') == 'fixed') ? (Math.max(0, ($(window).height() - (heigtImage + 90))/2)) : (Math.max(0, ($(window).height() - (heigtImage + 90))/2 + $(window).scrollTop())),
					left: (that.bigWrapper.css('position') == 'fixed') ? (Math.max(0, ($(window).width() - (widthImage + 50))/2)) : (Math.max(0, ($(window).width() - (widthImage + 50))/2 + $(window).scrollLeft()))
				}, 1000, function(){
					that.loadIcon.hide();
					that.inputFrame.css({
						height: heigtImage,
						width: widthImage,
						opacity: 1
					});
				});
				that.bigWrapper.find('#load-content').stop().animate({
					width: widthImage,
					height: heigtImage 
				},1000);
			};
			image.src = that.frameHref;
		}
	}
	var getUID = (function(){
		var id = 0;
		return function(){
			return 'cbox-' + id++;
		};
	})();
	Plugin.prototype = {
		init: function() {
			var plugin = this,
				that = plugin.element;
				that.vars = {};
				that.vars.thumbnailCol = that.children();
				that.vars.thumbnailLength = that.vars.thumbnailCol.length;
				that.vars.defaultsLink = plugin.options.defaultsLink;
				that.vars.index = 0;
				if(!$('.wrapper-popup').length){
					that.vars.bigWrapper = $('<div class="wrapper-popup"><div class="popup-type-1">'+
											'<span class="rnd tl"></span>' +
											'<span class="rnd tr"></span>' +
											'<span class="rnd bl"></span>' +
											'<span class="rnd br"></span>' +
											'<span class="rnd tm"></span>' +
											'<span class="rnd bm"></span>' +
											'<span class="rnd lm"></span>' +
											'<span class="rnd rm"></span>' +
											'<a title="'+ L10N.popup.close +'" href="javascript:void(0);" class="popup-close"></a>' +
											'<div class="popup-content">' +
												// '<div id="load-content" style="position:relative">' +
													// // set center with position as relative
													// // '<img class="loadIcon" style="position:relative;display:block;width:400px;margin: 0 auto;" src="../images/upload/loading.gif">' +
													// // set center with position as absolute
													// // '<img class="loadIcon" style="position:absolute;left: 50%; margin-left: -8px;" src="../images/loading.gif">' +
													// '<img class="loadIcon" style="position:absolute;left: 50%;top:50%;margin-left: -8px;" src="/sites/all/themes/dxo/images/loading.gif">' +
													// // '<img style="position:absolute" alt="" src="../images/upload/photo_imma_08.jpg">' +
													// '<a href="javascript:void(0);" >' +
														// '<img alt="" src="/images/upload/photo_imma_08.jpg">' +
													// '</a>' +	
												// '</div>' +
											'</div>' +
										'</div></div>').appendTo(document.body);					
				}
				if($('.wrapper-popup').length){
					that.vars.bigWrapper = $('.wrapper-popup');
				}
				if(plugin.options.navControl){
					that.vars.navControl = $('<div id="load-content" style="position:relative">' +
											'<img class="loadIcon" style="position:absolute;left: 50%;top:50%;margin-left: -8px;" src="/sites/all/themes/dxo/images/loading.gif">' +
												'<a href="javascript:void(0);" >' +
													'<img alt="" src="/images/upload/photo_imma_08.jpg">' +
												'</a>' +	
										'</div>' +
										'<div class="control-content">' +
											'<a title="'+ L10N.popup.prev +'" href="javascript:void(0);">' +
												'<span class="btn-pre">Previous</span>' +
											'</a>' +
											'<a title="'+ L10N.popup.next +'" href="javascript:void(0);">' +
												'<span class="btn-next">Next</span>' +
											'</a>' +
											'<span class="current-img">1/20</span>' +
										'</div>').appendTo(that.vars.bigWrapper.find('.popup-content'));
					that.vars.nextBtn = that.vars.bigWrapper.find('.btn-next').parent();
					that.vars.prevBtn = that.vars.bigWrapper.find('.btn-pre').parent();
					that.vars.currentImgIndex = that.vars.bigWrapper.find('.current-img');
					that.vars.imgIndex = that.vars.bigWrapper.find('.current-img');
					that.vars.loadIcon = that.vars.bigWrapper.find('.loadIcon');
					that.vars.imgLoading = that.vars.loadIcon.next().children();
				}
				if(!plugin.options.navControl){
					if(!that.vars.defaultsLink){
						that.vars.frameHref = that.attr('href');
					}
					if(that.vars.defaultsLink){
						that.vars.frameHref = that.children('img').attr('src');
					}
					if(!that.vars.bigWrapper.find('.popup-content').find('#load-content').length){
						that.vars.wrapperFrame = $('<div id="load-content" style="position:relative;width:500px;height:400px">' +
												'<img class="loadIcon" style="position:absolute;left: 50%;top:50%;margin-left: -8px;" src="/sites/all/themes/dxo/images/loading.gif">' +
											'</div>').appendTo(that.vars.bigWrapper.find('.popup-content'));
					}
					else if(that.vars.bigWrapper.find('.popup-content').find('#load-content').length){
						that.vars.wrapperFrame = $('#load-content');
					}
					that.vars.loadIcon = that.vars.bigWrapper.find('.loadIcon');						
				}
				that.vars.thumbnailCol.bind('click.showGallery', function(e){
					e.preventDefault();
					if(plugin.options.navControl){
						that.vars.index = $(this).index();
						that.vars.imgLoading.hide();
						that.vars.loadIcon.show();
						that.vars.currentImgIndex.html((that.vars.index + 1) + '/' + that.vars.thumbnailCol.length);
					}
					if(!plugin.options.navControl){
						if(!that.vars.defaultsLink){
							that.vars.frameHref = that.attr('href');
						}
						if(that.vars.defaultsLink){
							that.vars.frameHref = that.children('img').attr('src');
						}
						// that.vars.frameHref = $(this).parent().attr('href');
						that.vars.loadIcon.show();
						that.vars.classCheckForIfram = $(this).parent().is(plugin.options.classCheckForIfram);
					}
					that.vars.bigWrapper.smPopup('open',that.vars);
				});
				!that.vars.bigWrapper.data('smPopup') && that.vars.bigWrapper.css({
						display: 'none'
					}).smPopup({
						duration: 1000,
						btnClose: true,
						triggerClose: '.popup-close',
						beforeOpen: function(){
							if($('#cboxIframe').length && (!plugin.options.navControl)){
								$('#cboxIframe').hide();
								$('#cboxIframe').remove();
								$('#load-content').css({
									height: 400,
									width: 500
								});
							}
						},
						afterOpen: function($that){
							(plugin.options.navControl) && loadImage(that);
							(!plugin.options.navControl) && loadFrame($that);
						}
						// afterClose: function($that){
							// if(!plugin.options.navControl){
								// $that.wrapperFrame.css({
									// height: 400,
									// width: 500
								// });
								// (typeof $that.inputFrame !='undefined') && that.inputFrame.remove();
							// }
						// }
					});
				// !that.bigWrapper.data('smPopup') && that.bigWrapper.css({
					// display: 'none'
				// }).smPopup({
					// duration: 1000,
					// btnClose: true,
					// triggerClose: '.popup-close',
					// afterOpen: function(){
						// console.log($(this));
						// (plugin.options.navControl) && loadImage(that);
						// (!plugin.options.navControl) && loadFrame(that);
					// },
					// afterClose: function(){
						// if(!plugin.options.navControl){
							// that.wrapperFrame.css({
								// height: 400,
								// width: 500
							// });
							// that.inputFrame.remove();
						// }
					// }
				// });
			(plugin.options.navControl) && that.vars.nextBtn.unbind('click.next').bind('click.next', function(){
				that.vars.index ++;
				if(that.vars.index == that.vars.thumbnailCol.length){
					that.vars.index = 0;
				}
				that.vars.imgLoading.hide();
				that.vars.loadIcon.show();
				loadImage(that);
			});
			(plugin.options.navControl) && that.vars.prevBtn.unbind('click.prev').bind('click.prev', function(){
				that.vars.index --;
				if(that.vars.index == - 1){
					that.vars.index = that.vars.thumbnailCol.length - 1;
				}
				that.vars.imgLoading.hide();
				that.vars.loadIcon.show();
				loadImage(that);
			});
			(plugin.options.navControl) && that.vars.imgLoading.bind('click', function(){
				that.vars.nextBtn.trigger('click.next');
			});
			(plugin.options.navControl) && $(document).bind('keydown', function(e){
				e.preventDefault();
				if(e.which == 39){
					that.vars.nextBtn.trigger('click.next');
				}
				if(e.which == 37){
					that.vars.prevBtn.trigger('click.prev');
				}
			});
			that.vars.bigWrapper.smPopup('close',that.vars);
		},
		publicMethod: function(param) {
			
		},
		destroy: function() {
		
		}
	};

	$.fn[pluginName] = function(options, params) {
		return this.each(function() {
			var instance = $.data(this, pluginName);
			if (!instance) {
				$.data(this, pluginName, new Plugin(this, options));
			} else if (instance[options]) {
				instance[options](params);
			} else {
				console.warn(options ? options + ' method is not exists in ' + pluginName : pluginName + ' plugin has been initialized');
			}
		});
	};

	$.fn[pluginName].defaults = {
		navControl: true,
		classCheckForIfram: '.galleryphoto',
		defaultsLink: true
	};
}(jQuery, window));
/** showThumnailMenu **/
(function($, window, undefined) {
	var pluginName = 'smShowThumnailMenu';
	
	function Plugin(element, options) {
		this.element = $(element);
		this.options = $.extend({}, $.fn[pluginName].defaults, options);
		this.init();
	};

	Plugin.prototype = {
		init: function() {
			var plugin = this,
				that = plugin.element;
		},
		publicMethod: function(param) {
			
		},
		destroy: function() {
		
		}
	};

	$.fn[pluginName] = function(options, params) {
		return this.each(function() {
			var instance = $.data(this, pluginName);
			if (!instance) {
				$.data(this, pluginName, new Plugin(this, options));
			} else if (instance[options]) {
				instance[options](params);
			} else {
				console.warn(options ? options + ' method is not exists in ' + pluginName : pluginName + ' plugin has been initialized');
			}
		});
	};

	$.fn[pluginName].defaults = {
		
	};
}(jQuery, window));
/**
*
*smcustomScroll
*
**/
(function($, window, undefined) {
	var pluginName = 'smCustomScroll';
	var privateVar = null;
	var privateMethod = function() {

	};

	function Plugin(element, options) {
		this.element = $(element);
		this.options = $.extend({}, $.fn[pluginName].defaults, options);
		this.init();
	};
	
	Plugin.prototype = {
		init: function() {
			var plugin = this,
				that = plugin.element,
				draggable = false;
				that.contentArea = that.find(plugin.options.contentArea);
				that.wrapperContent = that.find(plugin.options.wrapperContent);
				that.scrollBar = that.find(plugin.options.scrollBar);
				that.scrollBarBtn = that.scrollBar.find(plugin.options.scrollBarBtn);
				that.ratioOfContenToScroll = that.contentArea.height() / (that.scrollBar.height() - that.scrollBarBtn.outerHeight());
				that.ratioOfWrapperToScroll = that.wrapperContent.height() / (that.scrollBar.height() - that.scrollBarBtn.outerHeight());
				that.firstY = 0;
				that.scrollBarBtnPos = 0;
				if (that.contentArea.height() >= that.wrapperContent.height()) {
					that.scrollBar.hide();
					return;
				}
				that.scroll = function (e, a) {
					var top = that.scrollBarBtn.position().top,
					preventDefault = true;
					if (e.keyCode == 40 || a < 0) {
						top += that.ratioOfWrapperToScroll * (that.contentArea.height() / ((that.ratioOfWrapperToScroll - that.ratioOfContenToScroll) * that.ratioOfWrapperToScroll));
						preventDefault = false;
					} else if (e.keyCode == 38 || a > 0) {
						top -= that.ratioOfWrapperToScroll * (that.contentArea.height() / ((that.ratioOfWrapperToScroll - that.ratioOfContenToScroll) * that.ratioOfWrapperToScroll));
						preventDefault = false;
					} else {
						preventDefault = true;
					}
					if (top <= 0)
						top = 0;
					if (top + that.scrollBarBtn.outerHeight() >= that.scrollBar.height())
						top = that.scrollBar.height() - that.scrollBarBtn.outerHeight();
					that.scrollBarBtn.css({
						'top' : top
					});
					that.wrapperContent.css({
						'margin-top' : -top * that.ratioOfWrapperToScroll + top * that.ratioOfContenToScroll
					});
					return preventDefault
				};
				that.scrollBarBtn.bind('mousedown.scrollBar', function (e) {
					draggable = true;
					that.firstY = e.pageY;
					that.scrollBarBtnPos = that.scrollBarBtn.position().top;
					return false
				});
				that.wrapperContent.bind('mousewheel.scrollBar', function (e, a) {
					that.scroll(e, a);
					return false
				});
				$(document).bind('mousewheel', function(){
					console.log(1);
				});
				that.scrollBar.bind({
					'click.scrollBar' : function (e) {
						var top = that.scrollBarBtn.position().top + (e.pageY - that.scrollBarBtn.offset().top) - that.scrollBarBtn.outerHeight() / 2;
						if (e.pageY - that.scrollBarBtn.outerHeight() < that.scrollBar.offset().top)
							top = 0;
						if (e.pageY + that.scrollBarBtn.outerHeight() >= that.scrollBar.offset().top + that.scrollBar.height())
							top = that.scrollBar.height() - that.scrollBarBtn.outerHeight();
						that.scrollBarBtn.css({
							'top' : top
						});
						that.wrapperContent.css({
							'margin-top' : -top * that.ratioOfWrapperToScroll + top * that.ratioOfContenToScroll
						})
					},
					'mousewheel.scrollBar' : function (e, a) {
						that.scroll(e, a);
						return false
					}
				});
				$(document).bind({
					'mousemove.scrollBar' : function (e) {
						e.preventDefault();
						if(draggable){
							var a = that.scrollBarBtnPos + (e.pageY - that.firstY);
							if (a <= 0)
								a = 0;
							if (a + that.scrollBarBtn.outerHeight() >= that.scrollBar.outerHeight())
								a = that.scrollBar.outerHeight() - that.scrollBarBtn.outerHeight();
							that.scrollBarBtn.css({
								'top' : a
							});
							that.wrapperContent.css({
								'margin-top' : -a * that.ratioOfWrapperToScroll + a * that.ratioOfContenToScroll
							})
						}
						return false
					},
					'mouseup.scrollBar' : function (e) {
						e.preventDefault();
						draggable = false;
						return false;
					},
					'keydown.scrollBar' : function (e) {
						return that.scroll(e)
					}
				});
				(that.scrollBarBtn.attr('href') == '#') && that.scrollBarBtn.attr('href', 'javascript:void(0);')
		},
		publicMethod: function(param) {

		},
		destroy: function() {
			
		}
	};

	$.fn[pluginName] = function(options, params) {
		return this.each(function() {
			var instance = $.data(this, pluginName);
			if (!instance) {
				$.data(this, pluginName, new Plugin(this, options));
			} else if (instance[options]) {
				instance[options](params);
			} else {
				console.warn(options ? options + ' method is not exists in ' + pluginName : pluginName + ' plugin has been initialized');
			}
		});
	};

	$.fn[pluginName].defaults = {
		contentArea : 'div.lst-type-1',
		wrapperContent : 'ul',
		scrollBar : '.scrollbar',
		scrollBarBtn : '.scrollbar-btn'
	};
}(jQuery, window));
/**
*
*smBlinkHover
*
**/
(function($, window, undefined) {
	var pluginName = 'smBlinkHover';
	var privateVar = null;
	var privateMethod = function() {

	};

	function Plugin(element, options) {
		this.element = $(element);
		this.options = $.extend({}, $.fn[pluginName].defaults, options);
		this.init();
	};
	
	Plugin.prototype = {
		init: function() {
			var plugin = this,
				that = plugin.element;
				that.hoverPoint = that.find(plugin.options.hoverPoint);
				that.blinkContent = that.find(plugin.options.blinkContent);
			that.hoverPoint.bind('mouseenter', function(e){
				e.preventDefault();
				that.blinkContent.removeClass('hidden');
			});
			that.bind('mouseleave', function(e){
				e.preventDefault();
				that.blinkContent.addClass('hidden');
			});
			
		},		
		publicMethod: function(param) {

		},
		destroy: function() {
		
		}
	};

	$.fn[pluginName] = function(options, params) {
		return this.each(function() {
			var instance = $.data(this, pluginName);
			if (!instance) {
				$.data(this, pluginName, new Plugin(this, options));
			} else if (instance[options]) {
				instance[options](params);
			} else {
				console.warn(options ? options + ' method is not exists in ' + pluginName : pluginName + ' plugin has been initialized');
			}
		});
	};

	$.fn[pluginName].defaults = {
		hoverPoint: '',
		blinkContent: ''
	};
}(jQuery, window));
/**
*
*customRadio
*
**/
(function($, window, undefined) {
	var pluginName = 'smCustomRadio';
	var privateVar = null;
	var privateMethod = function() {

	};

	function Plugin(element, options) {
		this.element = $(element);
		this.options = $.extend({}, $.fn[pluginName].defaults, options);
		this.init();
	};
	
	Plugin.prototype = {
		init: function() {
			var plugin = this,
				that = plugin.element,
				button = that.parent();
			button.each(function(){
				($(this).hasClass(plugin.options.checkedClass)) ? ($(this).children('input:radio').attr('checked','checked')) : ($(this).children('input:radio').removeAttr('checked'));
			});
			$.isFunction(plugin.options.init) && plugin.options.init.apply(that, arguments);
			button.unbind('click.customRadio').bind('click.customRadio', function(){
				if(!$(this).hasClass(plugin.options.checkedClass)){
					var name = $(this).children('input:radio').attr('name'),
						collection = $('input:radio').filter('[name="' + name + '"]'),
						current = $();
					collection.each(function(){
						if($(this).parent().hasClass(plugin.options.checkedClass)){
							current = $(this).parent();
						}
					});
					current.children('input:radio').removeAttr('checked');
					current.removeClass(plugin.options.checkedClass);
					$(this).children('input:radio').attr('checked', 'checked');
					$(this).addClass(plugin.options.checkedClass);
				$.isFunction(plugin.options.afterTicked) && plugin.options.afterTicked.call(that);	
				}
			});
			
		},		
		publicMethod: function(param) {

		},
		destroy: function() {
		
		}
	};

	$.fn[pluginName] = function(options, params) {
		return this.each(function() {
			var instance = $.data(this, pluginName);
			if (!instance) {
				$.data(this, pluginName, new Plugin(this, options));
			} else if (instance[options]) {
				instance[options](params);
			} else {
				console.warn(options ? options + ' method is not exists in ' + pluginName : pluginName + ' plugin has been initialized');
			}
		});
	};

	$.fn[pluginName].defaults = {
		checkedClass: 'rdBoxTypeChecked',
		init: function(){},
		afterTicked: function(){}
	};
}(jQuery, window));
/**
*
*customCheckbox
*
**/
(function($, window, undefined) {
	var pluginName = 'smCustomCheckbox';
	var privateVar = null;
	var privateMethod = function() {

	};

	function Plugin(element, options) {
		this.element = $(element);
		this.options = $.extend({}, $.fn[pluginName].defaults, options);
		this.init();
	};
	
	Plugin.prototype = {
		init: function() {
			var plugin = this,
				that = plugin.element,
				button = that.parent();
			that.is( ':checked' ) ? button.addClass(plugin.options.checkedClass) : button.removeClass( plugin.options.checkedClass );
			$.isFunction(plugin.options.init) && plugin.options.init.apply(that, arguments);
			button.unbind('click.ticked').bind('click.ticked', function() {
				if (button.hasClass(plugin.options.checkedClass)) {
					button.removeClass( plugin.options.checkedClass );
					that.removeAttr( 'checked' );
					that.val('0');
				} else {
					button.addClass( plugin.options.checkedClass );
					that.attr( 'checked', 'checked' );
					that.val('1');
				}
				$.isFunction(plugin.options.afterTicked) && plugin.options.afterTicked.call(that);
				return false;
			});
			// button.next( 'label' ).length && button.next( 'label' ).unbind('click.neighbor').bind('click.neighbor', function() {
				// button.trigger( 'click' );
				// return false;
			// });
		},		
		publicMethod: function(param) {

		},
		destroy: function() {
		
		}
	};

	$.fn[pluginName] = function(options, params) {
		return this.each(function() {
			var instance = $.data(this, pluginName);
			if (!instance) {
				$.data(this, pluginName, new Plugin(this, options));
			} else if (instance[options]) {
				instance[options](params);
			} else {
				console.warn(options ? options + ' method is not exists in ' + pluginName : pluginName + ' plugin has been initialized');
			}
		});
	};

	$.fn[pluginName].defaults = {
		checkedClass: 'chkBoxTypeChecked',
		init: function(){},
		afterTicked: function(){}
	};
}(jQuery, window));
/**
*
*shortenBlock
*
**/
(function($, window, undefined) {
	var pluginName = 'smShortenBlock';
	var privateVar = null;
	var privateMethod = function() {

	};

	function Plugin(element, options) {
		this.element = $(element);
		this.options = $.extend({}, $.fn[pluginName].defaults, options);
		this.init();
	};
	
	Plugin.prototype = {
		init: function() {
			var plugin = this,
				that = plugin.element;
				if(that.children().length > 1){
					return;
				}
				that.blockMenu = that.children(plugin.options.blockMenu);
				that.getWidth = $(plugin.options.getWidth).width();
				that.subtract = plugin.options.subtract;
				if(that.blockMenu.width() > that.getWidth){
					that.listCate = $('<div class="list-cat">' +
										// '<a class="more-cat" href="#"><img alt="" src="../images/transparent.png"></a>' +
										'<a class="more-cat" href="#"><img alt="" src="/sites/all/themes/dxo/images/transparent.png"></a>' +
										'<ul>' +
											// '<li><a title="Interface" href="#">Interface</a></li>' +
											// '<li><a title="Plugin" href="#">Plugin</a></li>' +
											// '<li><a title="Contrôle des couleurs" href="#">Contrôle des couleurs</a></li>' +
											// '<li><a title="Gestion des couleurs" href="#">Gestion des couleurs</a></li>' +
											// '<li><a title="Contrôle du noir et blanc" href="#">Contrôle du noir et blanc</a></li>' +
											// '<li><a title="Import/export de rendus" href="#">Import/export de rendus</a></li>' +
											// '<li><a title="Traitement par lot" href="#">Traitement par lot</a></li>' +
										'</ul>' +
									'</div>').appendTo(that);
					var widthVal = 0;
					that.show();
					that.blockMenu.children().each(function(index){
						if(widthVal + $(this).outerWidth() + that.subtract < that.getWidth){
							widthVal += $(this).outerWidth();
							if(index == that.blockMenu.children().length - 1){
								that.listCate.hide();
							} 
							// console.log(that.listCate.find('ul'))
							// console.log(widthVal)
						}
						else if(widthVal + $(this).outerWidth() + that.subtract > that.getWidth){
							widthVal += $(this).outerWidth();
							$(this).appendTo(that.listCate.find('ul'));
						}
					});
					// that.listCate.css({
						// top: that.listCate.children('a').offset().top
					// });
					that.hide();
				}
		},		
		publicMethod: function(param) {

		},
		destroy: function() {
		
		}
	};

	$.fn[pluginName] = function(options, params) {
		return this.each(function() {
			var instance = $.data(this, pluginName);
			if (!instance) {
				$.data(this, pluginName, new Plugin(this, options));
			} else if (instance[options]) {
				instance[options](params);
			} else {
				console.warn(options ? options + ' method is not exists in ' + pluginName : pluginName + ' plugin has been initialized');
			}
		});
	};

	$.fn[pluginName].defaults = {
		blockMenu: '.sub-nav-lev3',
		subtract: 121,
		getWidth: '#main'
	};
}(jQuery, window));
/**
*
*autoCreateCollapse
*
**/
(function($, window, undefined) {
	var pluginName = 'smAutoCreateCollapse';
	var privateVar = null;
	var privateMethod = function() {

	};

	function Plugin(element, options) {
		this.element = $(element);
		this.options = $.extend({}, $.fn[pluginName].defaults, options);
		this.init();
	};
	
	Plugin.prototype = {
		init: function() {
			var plugin = this,
				that = plugin.element;
				that.triggerCollapse = that.next();
				if(!that.triggerCollapse.is('a')){
					return;
				}
				that.maxHeight = that.height();
				that.minHeight = plugin.options.minHeight;
				that.css({
					height: that.minHeight,
					'overflow': 'hidden'
				});
				that.collapse = false;
			that.triggerCollapse.bind('click.expend', function(e){
				e.preventDefault();
				if(!that.collapse){
					that.collapse = true;
					that.animate({
						height: that.maxHeight
					});
				}
				else if(that.collapse){
					that.collapse = false;
					that.animate({
						height: that.minHeight
					});
				}
			});
		},		
		publicMethod: function(param) {

		},
		destroy: function() {
		
		}
	};

	$.fn[pluginName] = function(options, params) {
		return this.each(function() {
			var instance = $.data(this, pluginName);
			if (!instance) {
				$.data(this, pluginName, new Plugin(this, options));
			} else if (instance[options]) {
				instance[options](params);
			} else {
				console.warn(options ? options + ' method is not exists in ' + pluginName : pluginName + ' plugin has been initialized');
			}
		});
	};

	$.fn[pluginName].defaults = {
		minHeight: 75
	};
}(jQuery, window));
/**
*
* scrollAtLink
*
**/
(function($, window, undefined) {
	var pluginName = 'smScrollAtLink';
	var privateVar = null;
	var privateMethod = function() {

	};

	function Plugin(element, options) {
		this.element = $(element);
		this.options = $.extend({}, $.fn[pluginName].defaults, options);
		this.init();
	};
	
	Plugin.prototype = {
		init: function() {
			var plugin = this,
				that = plugin.element;
				if(that.hasClass('list-jobs')){
					return ;
				}
				that.item = that.find(plugin.options.item);
				var name = null;
				var scrollTop = 0;
				var win = $(window);
				var temp;
				that.item.bind('click', function(e){
					e.preventDefault();
					name = $(this).children('a').attr('href').split('#');
					temp = $('[name=' + name[1] + ']').offset().top;
					scrollTop = win.scrollTop();
					that.stop().animate({
						'property': 1
					},{
						duration: 800,
						easing: 'swing',
						step: function(now, fx){
							win.scrollTop(scrollTop + (fx.pos*(temp - scrollTop)));
						}
					});
				});
		},		
		publicMethod: function(param) {

		},
		destroy: function() {
		
		}
	};

	$.fn[pluginName] = function(options, params) {
		return this.each(function() {
			var instance = $.data(this, pluginName);
			if (!instance) {
				$.data(this, pluginName, new Plugin(this, options));
			} else if (instance[options]) {
				instance[options](params);
			} else {
				console.warn(options ? options + ' method is not exists in ' + pluginName : pluginName + ' plugin has been initialized');
			}
		});
	};

	$.fn[pluginName].defaults = {
		item: '.item'
	};
}(jQuery, window));